package com.dietmanager.model;

import java.util.ArrayList;

/**
 * The Class Workout.
 */
public class Workout extends ExerciseModel {
	private static final long serialVersionUID = 1883453496635516328L;
	private ArrayList<ExerciseModel> exercises = new ArrayList<>();
	private String repetitions;
	
	/**
	 * Instantiates a new workout.
	 *
	 * @param name the name
	 * @param calories the calories
	 * @param minutes the minutes
	 */
	public Workout(String name, int calories, float minutes) {
		super(name, calories, minutes);
	}

	/**
	 * Gets the repetitions.
	 *
	 * @return the repetitions
	 */
	public String getRepetitions() {
		return repetitions;
	}
	
	/**
	 * Sets the repetitions.
	 *
	 * @param repetitions the new repetitions
	 */
	public void setRepetitions(String repetitions) {
		this.repetitions = repetitions;
	}

	/**
	 * Adds a ExerciseModel.
	 *
	 * @param exercise the exercise
	 */
	public void add(ExerciseModel exercise) {
		exercises.add(exercise);
	}

	/**
	 * Removes a ExerciseModel.
	 *
	 * @param exercise the exercise
	 */
	public void remove(ExerciseModel exercise) {
		exercises.remove(exercise);
	}

	/**
	 * Gets the calories.
	 *
	 * @return the calories
	 */
	@Override
	public int getCalories() {
		int totalCalories = 0;
		for(ExerciseModel exercise : exercises) 
			totalCalories += exercise.getCalories();
		
		return totalCalories;
	}

	/**
	 * Gets the minutes.
	 *
	 * @return the minutes
	 */
	@Override
	public float getMinutes() {
		float totalMinutes = 0;
		for(ExerciseModel exercise : exercises) 
			totalMinutes += exercise.getMinutes();
		
		return totalMinutes;
	}
}
